package com.yc.navy.vote.bean;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.yc.navy.mybatis.util.StringUtil;

public class Topics {
	private String tid;
	private String tname;
	private Integer types;
	private Integer usid;
	private String sdate;
	private String edate;
	private String usids;
	private Integer status =0; //1.未开始 2 .已结束 3.已投票
	private Integer count =0; //记录有多少人参与投票了
	private Integer nums =0; //选项的个数
	
	private String uname; //用户名
	private List<TopicItem> topicItems;
	


	@Override
	public String toString() {
		return "Topics [tid=" + tid + ", tname=" + tname + ", types=" + types + ", usid=" + usid + ", sdate=" + sdate
				+ ", edate=" + edate + ", usids=" + usids + ", status=" + status + ", count=" + count + ", nums=" + nums
				+ ", uname=" + uname + "]";
	}
	
	
	
	public Integer getNums() {
		return nums;
	}



	public void setNums(Integer nums) {
		this.nums = nums;
	}



	public String getTid() {
		return tid;
	}

	public void setTid(String tid) {
		this.tid = tid;
	}

	public String getTname() {
		return tname;
	}

	public void setTname(String tname) {
		this.tname = tname;
	}

	public Integer getTypes() {
		return types;
	}

	public void setTypes(Integer types) {
		this.types = types;
	}

	public Integer getUsid() {
		return usid;
	}

	public void setUsid(Integer usid) {
		this.usid = usid;
	}

	public String getSdate() {
		return sdate;
	}

	public void setSdate(String sdate) {
		this.sdate = sdate;
		
		try {
			SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
			Date date = sdf.parse(sdate);
			Date date1= new Date();
			if(date.after(date1)) {
				this.status = -1;  //说明未开始投票
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
	}

	public String getEdate() {
		return edate;
	}

	public void setEdate(String edate) {
		this.edate = edate;
		
		try {
			SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
			Date date = sdf.parse(sdate);
			Date date1= new Date();
			if(date.after(date1)) {
				this.status = 2;  //说明投票已经结束
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	public String getUsids() {
		return usids;
	}

	public void setUsids(String usids) {
		this.usids = usids;
		
		if(!StringUtil.checkNull(usids)) {
			usids = usids.substring(1);
		}
		
		this.usids=usids;
		
		if(!StringUtil.checkNull(usids)) {
			this.count =usids.split(",").length;
		}
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public String getUname() {
		return uname;
	}

	public void setUname(String uname) {
		this.uname = uname;
	}

	public List<TopicItem> getTopicItems() {
		return topicItems;
	}

	public void setTopicItems(List<TopicItem> topicItems) {
		this.topicItems = topicItems;
	}
	
	
}
